home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 for Intel / NeXTSTEP 3.2 for Intel.iso / NextLibrary / Documentation / Sybase / DBLIB / Section2 / dbconvert.ex < prev    next >
Encoding:
Text File  |  1993-04-22  |  767 b   |  25 lines

  1. DBCHAR        title[81];
  2. DBCHAR        price[9];
  3.  
  4. /* read the query into the command buffer */
  5. dbcmd(dbproc, "select title, price, royalty from pubs..titles");
  6.  
  7. /* send the query to \*S */
  8. dbsqlexec(dbproc);
  9.  
  10. /* get ready to process the results of the query */
  11. dbresults(dbproc);
  12.  
  13. /* process each row */
  14. while (dbnextrow(dbproc) != NO_MORE_ROWS)
  15. {
  16.     /* the first dbconvert() adds a null terminator to the string */
  17.     dbconvert(dbproc, SYBCHAR, (dbdata(dbproc,1)), (dbdatlen(dbproc,1)), 
  18.         SYBCHAR, title, (DBINT)-1);
  19.     /* the second dbconvert() converts money to string */
  20.     dbconvert(dbproc, SYBMONEY, (dbdata(dbproc,2)), (DBINT)-1, SYBCHAR, price, (DBINT)-1);
  21.  
  22.     if (dbdatlen(dbproc,3) != 0)
  23.         printf ("%s\en $%s  %ld\en", title, price, *((DBINT *)dbdata(dbproc,3)));
  24. }
  25.